<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />

	<link rel="stylesheet" type="text/css" href="__HOME__/css/stoplist.css"/>
	<script type="text/javascript" src="__HOME__/js/jquery.min.js"></script>
	<script type="text/javascript" src="__HOME__/layer/layer.js"></script>
	<script type="text/javascript" src="__HOME__/js/address.js" charset=”gb2312″></script>
	<title>新增地址</title>
</head>
<body onload="setup();preselect('河南省');">
	<div class="wrap">
		<div class="header">
        	<i><a href="#" onclick="window.opener=null;window.close();window.history.back();" >×</a></i>
        	<p>新增地址</p>
        </div>
        
        <div class="content">
        	<form id="form1" action="{:url('Cydia/add')}" method="POST">
        		<div class="input-field">
		            <div class="title">收货人：</div>
		            <input id="username" type="text" name="name" value="" placeholder="请输入收货人姓名">
        		</div>
        		
        		 <div class="input-field">
		            <div class="title">手机号：</div>
		            <input id="phone" type="text" name="tel" value="" placeholder="请输入收货人联系电话">
        		</div>
	
				<div class="city-picker-select">
					<select class="select" name="province" id="s1">
					  	<option></option>
					</select>
					<select class="select" name="city" id="s2">
					  	<option></option>
					</select>
					<select class="select" name="district" id="s3">
					  	<option></option>
					</select>
				</div>
				

        		 <div class="input-field">
		            <div class="title">详细地址：</div>
		            <input id="addr" type="text" name="address" value="" placeholder="请输入您的详细地址">
        		</div>
    		
    			<!--提交按钮写在form表单外就不会执行-->
    			<input type="button" id="tj" class="tab" value="保存" />
        	</form>
        </div><!--内容层-->
	</div><!--包裹层-->
		
		
<!--判断内容是否为空-->	
<script>
	$(function(){
		
		$('#tj').click(function(){
		
			if(!$('#username').val()){
				
				layer.msg("收件人不能为空");
				return false;
			
			}else{

				if(!$('#phone').val()){
				
					layer.msg("手机号不能为空");
					return false;
				
				}else{

					if(!$('#addr').val()){
				
						layer.msg("详细地址不能为空");
						return false;
					
					}else{

						$.post("{:url('Cydia/add')}",{
							'name':$('#username').val(),
							'tel':$('#phone').val(),
							'province':$('#s1').val(),
							'city':$('#s2').val(),
							'district':$('#s3').val(),
							'address':$('#addr').val()
						},function(res){
							if(res.code==1){
								layer.msg(res.msg);
								location.href = "{:url('Address/index')}";
							}else{
								layer.msg(res.msg);
							}
						});
					}
				}
			}
			
			
			 
			
		
		});

	})



</script>
	
</body>
</html>